package com.cy.pj.sys.controller;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.cy.pj.common.bo.PageObject;
import com.cy.pj.common.vo.JsonResult;
import com.cy.pj.sys.entity.SysRole;
import com.cy.pj.sys.service.SysRoleService;

@RestController //@Controller+@ReponseBody
@RequestMapping("/role/")
public class SysRoleController {
    
	 @Autowired
	 private SysRoleService sysRoleService;
     
     @RequestMapping("doFindRoles")
     public JsonResult doFindRoles() {
    	 
    	 return new JsonResult(sysRoleService.findObjects());
     }
     
     @RequestMapping("doFindObjectById")
     public JsonResult doFindObjectById(Integer id) {
    	 return new JsonResult(sysRoleService.findObjectById(id));
     }
     
     @RequestMapping("doUpdateObject")
     public JsonResult doUpdateObject(SysRole entity,Integer[]menuIds) {
    	 sysRoleService.updateObject(entity, menuIds);
    	 return new JsonResult("update ok");
     }
     
     @RequestMapping("doSaveObject")
     public JsonResult doSaveObject(SysRole entity,Integer[]menuIds) {
    	 sysRoleService.saveObject(entity, menuIds);
    	 return new JsonResult("save ok");
     }
     
     @RequestMapping("doDeleteObject")
     public JsonResult doDeleteObject(Integer id) {
    	 sysRoleService.deleteObject(id);
    	 return new JsonResult("delete ok");
     }
     
     @RequestMapping("doFindPageObjects")
     public JsonResult doFindPageObjects(String name,Integer pageCurrent) {
    	 PageObject<SysRole> pageObject=
    	 sysRoleService.findPageObjects(name, pageCurrent);
    	 return new JsonResult(pageObject);
     }
     
 	/**
 	 * 导出数据到excel
 	 * @return
 	 */
 	@RequestMapping("exportExcel")
 	public Map<String,Object> exportExcel(HttpServletRequest request,HttpServletResponse response) {
 		Map<String, Object> result = sysRoleService.exportExcel(request, response);
 		return result;
 	}
     
}




